/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DSENS;
import java.util.ArrayList;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 *
 * @author filippo
 */
public class CreateFileDot {

    static void printDot (ArrayList<Node> net) {
        FileWriter dotfw;
        File dotfile = new File("Grafico.dot");

        try{
            dotfw = new FileWriter(dotfile);
        
        int size = net.size(), i, j, nodeid;

        dotfw.write("digraph prova {\n");
        for(i = 0; i < size; i++) {
            int neighbsize = net.get(i).neighborood.size();
            nodeid = net.get(i).ID;
            for(j = 0; j < neighbsize; j++)
                dotfw.write(nodeid +" -> "+ net.get(i).getNeighbour(j).getId()+"[dir = none];\n");            
        }
        dotfw.write("}\n");
        dotfw.flush();
        dotfw.close();
        } catch (IOException e){}
        try{
            Runtime rt = Runtime.getRuntime();
            Process proc = rt.exec("dot "+dotfile.getPath()+" -Tgif -o graph1.gif");
        } catch(Exception e){}

    }
}
